"use client"; // 添加这一行，使组件变为 Client Component
import { useDragLayer } from "react-dnd";
import style from "./index.module.css"
interface MyComponentProps {
    targetId?: string
    id?: string
}
const DragLayer: React.FC<MyComponentProps> = (props) => {
    const { isDragging, item, currentOffset } = useDragLayer((monitor) => ({
        item: monitor.getItem(),
        isDragging: monitor.isDragging(),
        currentOffset: monitor.getSourceClientOffset(),
    }));

    if (!isDragging) {
        return null;
    }
    return (
        <div className={style.draglayer } style={{
            left: currentOffset?.x,
            top: currentOffset?.y,
            transform: "translate(-50%, -50%)",
             position: "fixed"
        }}>拖拖拖</div>
    );
}
export default DragLayer;
